#define	STOPPING_CONDITION	90 //seconds.
#define	DISCARD	25		  //seconds

typedef struct performance_t {

	double total_time;

	double interval_time;
	double interval_proposing_throughput;
	double interval_sending_throughput;
	double interval_delivery_throughput;
	double interval_recv_throughput;
	double interval_latency;
	double interval_bytes_sent;
	double interval_bytes_recv;
	double interval_bytes_proposed;

	int interval_num_packets_propsoed;
	int interval_num_packets_delivered;
	int num_packets_delivered_latency;
	int latency_counter;
	double latency_avg;
	double latency_sd;
	double latency_sq_sum;
	double latency_sum;
	double diff;
	int num_interrupts;

} performance;

performance * interval_performance;
performance performances[STOPPING_CONDITION];
int performance_index;
const char * performance_file;
const char * latency_file;
const char * sd_avg_file;
void compute_performance(int sd, short event, void* arg);
void nulify_performance(performance * p);
void print_performance(performance * p);
double measure_time_difference(struct timeval now, struct timeval past);
double calculate_throughput(int bytes, double elapsed_time);
void store_performance_in_array(performance * performances_array, int * performance_index, performance *i_p);
void store_performance_in_file(const char * performance_file, const char * latency_file, const char * sd_avg_file, int num_entries);

